<?php
/**
 * 文章管理
 *
 *
 *
 *
 */
namespace Common\Model;
use Common\Model\BaseModel;

class LottreyModel extends BaseModel{
	/**
	 * 下注订单列表
	 *
	 * @param array $condition 检索条件
	 * @param   $page 分页
	 * @return array 数组结构的返回结果
	 */
	public function getOrderList($condition,$page=''){
		
		$condition_str = $this->_condition1($condition);
		 
		$param = array();
		$m=M('lottery_order');
 		$param['where'] = $condition_str;
 		$param['order']	= (empty($condition['order'])?'order_id desc,add_time desc':$condition['order']);
 		 
 		$result =$this->getPage($m,$param['where'],$param['order'],$page);
 		return $result;
	}

 

	 
/**
	 * 构造检索条件
	 *
	 * @param int $id 记录ID
	 * @return string 字符串类型的返回结果
	 */
	private function _condition1($condition){
		$condition_str = '1';

		if ($condition['status'] ==1){
			$condition_str .= " and status = '". $condition['status'] ."'";
		}elseif($condition['status']==2){
			$condition_str .= " and status=0";
		}elseif($condition['status']==10){
			$condition_str .= " and status=10";
		}
		if ($condition['order_sn'] != ''){
			$condition_str .= " and order_sn like '%". $condition['order_sn'] ."%' ";
		}
		if ($condition['c_id'] != ''){
			$condition_str .= " and c_id = '". $condition['c_id'] ."'";
		} 
		if ($condition['m_id'] != ''){
			$condition_str .= " and m_id = '". $condition['m_id'] ."'";
		}
		if ($condition['strtime'] != '' || $condition['endtime'] != ''){
			$condition_str .= " and add_time between '".strtotime($condition['strtime'])."' and '".strtotime($condition['endtime'])."'";
		}
		
		return $condition_str;
	}
	 
 

	 

	 
}